package com.justgame.project.cloud.common.constant;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.time.Duration;

/**
 * 系统常量
 */
@Data
@Component
@Slf4j
@SuppressWarnings("all")
public class Const {

    public final static Long V = 1L;
    //    处理请求成功
    public final static Integer RES_COMMON_SUCCESS = 200;
    //    处理请求失败
    public final static Integer RES_COMMON_ERROR = 500;
    //    错误的访问路径
    public final static Integer RES_ERROR_PATH = 404;
    public final static String RES_ERROR_PATH_CHINESE = "路径不存在，请检查路径是否正确！";
    //    请求方法错误
    public final static Integer RES_ERROR_METHOD = 405;
    public final static String RES_ERROR_METHOD_CHINESE = "该方法不支持当前请求方式，请检查后重试！";
    //    权限不足
    public final static Integer RES_ERROR_AUTHORIZATION = 403;
    public final static String RES_ERROR_AUTHORIZATION_CHINESE = "权限不足，服务器拒绝了您的访问。";
    //    输入的验证码是错误的
    public final static Integer RES_ERROR_BAD_VERIFICATION_CODE = 100;
    public final static String RES_ERROR_BAD_VERIFICATION_CODE_CHINESE = "验证码错误，请重新输入。";
    //    Redis缓存中的用户信息
    public final static String KEY_REDIS_USER = "JustGameInfo:Cache:SimpleAccount:";
    //    临时文件
    public final static String KEY_TEMP_FILES = "JustGameInfo:Temp:TempFiles";
    //    已删除的临时文件目录，等待更新到数据库
    public final static String KEY_CLEARED_FILES = "JustGameInfo:Temp:ClearedFiles";
    //    Redis缓存文章观看次数
    public final static String KEY_REDIS_WATCH_PAGE_COUNT = "JustGameInfo:Count:PageWatchCount:";
    //    Redis缓存点赞观看次数
    public final static String KEY_REDIS_LIKE_PAGE_COUNT = "JustGameInfo:Count:PageLikeCount:";
    //    Redis缓存点赞观看次数
    public final static String KEY_REDIS_SHARE_PAGE_COUNT = "JustGameInfo:Count:PageShareCount:";
    //    Redis缓存点赞观看次数
    public final static String KEY_REDIS_COMMENT_PAGE_COUNT = "JustGameInfo:Count:PageCommentCount:";
    //    Redis缓存中所有系统平台信息
    public final static String KEY_REDIS_PLATFORM_INFO = "JustGameInfo:Cache:SysPlatform";
    //    Redis缓存中所有游戏平台
    public final static String KEY_REDIS_GAME_PLATFORM = "JustGameInfo:Cache:GamePlatform";
    //    Redis缓存中所有账户状态信息
    public final static String KEY_REDIS_TOTAL_STATUS = "JustGameInfo:Cache:AccountStatus";
    // Reids中存放Token的Key模板头
    public final static String KEY_REDIS_TOKEN_HEAD = "JustGameInfo:token:";
    // Reids中存放Token的Key模板头
    public final static String KEY_REDIS_TOKEN_CURRENT = "JustGameInfo:current_token:";
    //    Redis缓存行政区划
    public final static String KEY_REDIS_AREA = "JustGameInfo:Area";
    //    Redis缓存行政区划
    public final static String KEY_REDIS_API = "JustGameInfo:Api";
    // 默认的Token盐
    public final static String DEFAULT_SALT_TOKEN = "d64&05$a729#%1ie0xf3";
    // 默认的密码盐
    public final static String DEFAULT_SALT_PASSWORD = "&7k8e1x&^o%$*!9a$ds1";
    // 默认的验证码盐值
    public final static String DEFAULT_SALT_VERIFICATION = "#21Ds$#/es289!(w";
    //  验证码的key —— Redis
    public final static String KEY_VERIFICATION_CODE_2REDIS = "JustGameInfo:Cache:VerificationCode";
    //  验证码的key —— Web
    public final static String KEY_VERIFICATION_CODE_2WEB = "code";
    //  首页板报的key —— Redis
    public final static String KEY_HOME_COLUMNS = "JustGameInfo:Cache:HomeColumns";
    //  不同用户的所属角色key —— Redis
    public final static String KEY_USER_ROLES = "JustGameInfo:Cache:UserRoleMap";
    //  查询条件无效
    public final static String RES_BAD_PARAMS_CHINESE = "请求参数不匹配！";
    public final static Integer RES_BAD_PARAMS = 420;
    /**
     * About Token
     */
    //  Token过期
    public final static Integer CODE_TOKEN_OUTDATED = 300;
    public final static String CODE_TOKEN_OUTDATED_CHINESE = "您的token已过时，请重新登陆。";
    // Token信息与DB信息不符
    public final static Integer CODE_TOKEN_MISMATCH = 301;
    public final static String CODE_TOKEN_MISMATCH_CHINESE = "token信息不匹配，请重新登陆。";
    // 账户被禁止登陆
    public final static Integer CODE_TOKEN_BAN = 302;
    public final static String CODE_TOKEN_BAN_CHINESE = "抱歉，该账户已被限制登陆，因此我们暂时无法为该账户提供服务。";
    // Token不存在或者未授权
    public final static Integer CODE_TOKEN_INVALID = 303;
    public final static String CODE_TOKEN_INVALID_CHINESE = "您还未登录，请先登录。";
    // Token不存在或者未授权
    public final static Integer CODE_TOKEN_EMPTY = 350;
    public final static String CODE_TOKEN_EMPTY_CHINESE = "不允许没有token访问";
    public final static Long TIME_NO_EXPIRE = 9999999L;
    public final static Long TIME_TIMEOUT_TOKEN = Duration.ofHours(1).getSeconds();

    /**
     * 订单备注信息
     */
    public final static String REMARK_GAME_ORDER = "游戏购买订单";


    /**
     * 普通的常量
     */
    // 注册信息中最 少 的用户名长度
    public final static Integer MIN_ACCOUNT_LENGTH = 3;
    // 注册信息中最 多 的用户名长度
    public final static Integer MAX_ACCOUNT_LENGTH = 16;
    // 注册信息中最 少 的密码长度
    public final static Integer MIN_PASSWORD_LENGTH = 3;
    // 注册信息中最 多 的用户名长度
    public final static Integer MAX_PASSWORD_LENGTH = 20;
    // 装配路径
    public final static String LOCAL_PATH = System.getProperty("user.dir");
    /**
     * File
     */
    public final static String UserFilesPath = "/userFiles/";
    public final static String SystemFilesPath = "/systemFiles/";
    public final static String OtherFilesPath = "/tempFiles/";
    /**
     * Feign
     */
    public final static String FEIGN_REQUEST_HEADER_AUTH = "feign_auth";
    public final static String FEIGN_REQUEST_HEADER_APP_NAME = "feign_application_name";
    public final static String FEIGN_REQUEST_REDIS_AUTH = "JustGameInfo:FeignAuth:";
    public final static String NOT_FEIGN_REQUEST_MSG = "服务器已拒绝您的内部接口访问请求！";
    /**
     * EventBus CODE
     */
    public final static String RefreshRedis_TotalUser = "RefreshRedis_TotalUser";
    public static String OSS_BUCKET_NAME;
    public static String OSS_ACCESS_KEY_SECRET;
    public static String OSS_ACCESS_KEY_ID;
    public static String OSS_ENDPOINT;
    public final static String REQUEST_START_TIME = "_startTime";
    @Value("${bucket:just-game}")
    public void setOssBucketName(String ossBucketName) {
        log.info("bucket:{}",ossBucketName);
        OSS_BUCKET_NAME = ossBucketName;
    }

    @Value("${secret:BsVc6eZOwOVcLMFvKziRsPrgd8Z4G6}")
    public void setOssAccessKeySecret(String ossAccessKeySecret) {
        log.info("secret:{}",ossAccessKeySecret);
        OSS_ACCESS_KEY_SECRET = ossAccessKeySecret;
    }

    @Value("${accessKeyId:LTAI5t88p8PTk2HGGbwPUd6x}")
    public void setOssAccessKeyId(String ossAccessKeyId) {
        log.info("accessKeyId:{}",ossAccessKeyId);
        OSS_ACCESS_KEY_ID = ossAccessKeyId;
    }

    @Value("${endpoint:oss-cn-beijing.aliyuncs.com}")
    public void setOssEndpoint(String ossEndpoint) {
        log.info("endpoint:{}",ossEndpoint);
        OSS_ENDPOINT = ossEndpoint;
    }

    /**
     * Email - Verification Code
     */
    public static String EMAIL_VALIDATION_CODE = "MailCode::";
    /**
     * Email - Send Time
     */
    public static String EMAIL_VALIDATION_TIMEOUT = "JustGameInfo:Email:TimeOut";
    /**
     * Email - 发送验证码次数
     */
    public static String EMAIL_VALIDATION_COUNT = "JustGameInfo:Email:Count";
    /**
     * Email - 发送验证码次数
     */
    public static Integer EMAIL_VALIDATION_MAX_COUNT = 10;
}
